Skip to content

fix: report task output metrics in Spark UI#3999

Merged
comphead merged 3 commits intoapache:mainfrom
0lai0:WrittenByte_UI
Apr 22, 2026
Merged

fix: report task output metrics in Spark UI#3999
comphead merged 3 commits intoapache:mainfrom
0lai0:WrittenByte_UI

Conversation

@0lai0
Copy link
Copy Markdown
Contributor

@0lai0 0lai0 commented Apr 20, 2026

Which issue does this PR close?

Part of #3996
Closes #3608

Rationale for this change

Native Parquet writes executed by Comet were updating SQL metrics (bytes_written, rows_written) but not Spark task-level OutputMetrics. Spark UI Stages displays the Output column from task metrics, so native write stages could show empty output even when files were successfully written.
This change aligns native write metrics reporting with Spark UI expectations by propagating native write totals to task-level output metrics.

What changes are included in this PR?

  • Add reportNativeWriteOutputMetrics in CometMetricNode to bridge native writer SQL metrics to Spark task-level OutputMetrics (bytesWritten, recordsWritten) at task completion.
  • Register this reporting hook in CometNativeWriteExec before creating CometExecIterator, so final native metric updates are available when completion listeners run.

How are these changes tested?

Added/ran targeted ScalaTest
image


spark.sparkContext.listenerBus.waitUntilEmpty()

assert(outputBytes.nonEmpty, "No task reported outputMetrics.bytesWritten")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the test for input metrics, we def need to ensure number of rows are the same. for bytes we need to have some approximation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll update in next commit. Thanks @comphead for review.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Now assert recordsWritten with exact equality, and use the existing suite convention for bytes approximation (ratio in 0.7–1.3), consistent with other input-metrics checks in CometTaskMetricsSuite.

Copy link
Copy Markdown
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @0lai0 it is LGTM

@comphead comphead merged commit dae02c0 into apache:main Apr 22, 2026
132 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native writer doesn't report written bytes

2 participants